<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ page import="org.tobuy.vo.*" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>User Info</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
   <body>
  <%
  	User current_user = (User)session.getAttribute("user");
  	User user = (User)request.getAttribute("user");
  	List<Score> buyscores = (ArrayList<Score>)request.getAttribute("buyscores");
  	List<Score> sellscores = (ArrayList<Score>)request.getAttribute("sellscores");
  	String buyscore_info = new String();
  	String sellscore_info = new String();
		int buysum_score = 0;
		int sellsum_score = 0;
		Iterator<Score> biter = buyscores.iterator();
		Iterator<Score> siter = sellscores.iterator();
		while(biter.hasNext()){
			Score score = biter.next();
			buysum_score = score.getScore_value()+buysum_score;
		}
		while(siter.hasNext()){
			Score score = siter.next();
			sellsum_score = score.getScore_value()+sellsum_score;
		}
		if(buyscores.size()>0){ buyscore_info = "average " + buysum_score/buyscores.size() + " from " +buyscores.size() + " time(s)."; }else{ buyscore_info = "Haven't got any score from customers."; }
		if(sellscores.size()>0){ sellscore_info = "average " + sellsum_score/sellscores.size() + " from " +sellscores.size() + " time(s)."; }else{ sellscore_info = "Haven't got any score from customers."; }
  	%>
  		<h3>User Id:<%=user.getUser_id() %></h3>
  		<h3>User Name:<%=user.getUser_name() %></h3>
  		<h3>User Address:<%=user.getAddress() %></h3>
  		<h3>Selling Score:<%=sellscore_info %></h3>
  		<h3>Buying Score:<%=buyscore_info %></h3>
  	<%
  	if(!current_user.getUser_id().equals(user.getUser_id())){
  		%>
  		
  			
  			
  		
  		<%
  	}
  	
  
   %>
 

  </body>
</html>
